package tump.tree.二叉查找树;

public class BinarySearchTree<AnyType extends Comparable<? extends AnyType>> {
    /**
     * 定义二叉查找树的节点数据结构
     */
    private static class BinaryNode<AnyType> {
        BinaryNode(AnyType theElement) {
            this(theElement, null, null);
        }

        BinaryNode(AnyType theElement, BinaryNode<AnyType> lt, BinaryNode<AnyType> rt) {
            element = theElement;
            left = lt;
            right = rt;
        }

        AnyType element;
        BinaryNode<AnyType> left;
        BinaryNode<AnyType> right;
    }

    private BinaryNode<AnyType> root;

    public BinarySearchTree() {
        root = null;
    }

    public void makeEmpty() {
        root = null;
    }

    /**
     * 判断是否为空 true:空集 false:非空
     */
    public boolean isEmpty() {
        return root == null;
    }

    public boolean contains(AnyType x){
        // TODO: 2019/2/3 return contains(x,root);
    }

    public AnyType findMin(){
        if(isEmpty()){
            throw new RuntimeException("树为空,无法findMin");
        }
        // TODO: 2019/2/3  return findMin(root).element;
    }

    public void  insert(AnyType x){
        // TODO: 2019/2/3 root=insert(x,root);
    }

    public void remove(AnyType x){
        // TODO: 2019/2/3 root=remove(x,root);
    }

    public void printTree(){
        // TODO: 2019/2/3 printTree
    }

    private <AnyType extends Comparable<? super AnyType>> boolean contains(AnyType x,BinaryNode<AnyType> t){
        if(t == null){
            return false;
        }
        int campareResult = x.compareTo(t.element);

    }

    

}
